<?php
declare(strict_types=1);
namespace App\Controller\WebApi\v1;

use App\Controller\AbstractController;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\HttpServer\Annotation\Controller;
use App\Middleware\WebApiMiddleware;
use Hyperf\HttpServer\Annotation\Middleware;
use Service\UserService\UserService;
use Hyperf\Di\Annotation\Inject;

/**
 * 用户授权中心
 * @author chenshubo
 * @Controller(prefix="/webapi/v1/login")
 * @Middleware(WebApiMiddleware::class)
 */
class UserLoginController extends AbstractController
{
    /**
     * @Inject()
     * @var UserService
     */
    protected $userService;
    
    /**
     * 登录接口
     * @RequestMapping(path="login", methods="post")
     */
    public function login(RequestInterface $request)
    {
        return $this->userService->login(
            (int)$request->input('cid'),
            (int)$request->input('mnid'),
            (int)$request->input('mn_sid'),
            (string)$request->input('client'),
            [
                'js_code'       => $request->input('js_code'),
                'mobile'        => $request->input('mobile'),
                'password'      => $request->input('password'),
                'code'          => $request->input('code'),
                'openid'        => $request->input('openid'),
                'nickname'      => $request->input('nickname'),
                'img'           => $request->input('img'),
                'guide_code'    => $request->input('guide_code'),
                'unionid'       => $request->input('unionid'),
            ]
        );
    }
}